<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改学员')" />
	<th:block th:include="include :: select2-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body>
    <div class="main-content">
        <form class="form-horizontal" id="form-user-edit" th:object="${student}">
            <input name="studentId"  type="hidden"  th:field="*{studentId}" />
            <div class="form-group draggable">
                <label class="col-sm-3 control-label">日期选择：</label>
                <div class="col-sm-9">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="locusTime" id="locusTime" type="locusTime" class="form-control" value="2018-04-20">
                    </div>
                </div>
            </div>
            <div class="form-group draggable">
                <label class="col-sm-3 control-label">指导老师：</label>
                <div class="col-sm-9">
                    <div class="input-group date">
                        <input name="userName" onclick="selectUser()" id="userName" type="text" placeholder="请选择用户" class="form-control">
                        <input name="userId" style="display: none" id="userId" type="text" class="form-control">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group draggable">
                <label class="col-sm-3 control-label">当前状态：</label>
                <div class="col-sm-9">
                    <div class="input-group date">
                        <select name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_student_status')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
           <!-- <div class="form-group draggable">
                <label class="col-sm-3 control-label">当前状态:</label>
                <div class="col-sm-9">
                    <select name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_student_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>-->
            <div class="form-group draggable">
                <label class="col-sm-3 control-label">备注内容：</label>
                <div class="col-sm-9">
                    <input name="content" id="content" type="hidden">
                    <div class="summernote"></div>
                </div>
            </div>

        </form>
    </div>

    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
    <th:block th:include="include :: summernote-js" />
    <script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
    <th:block th:include="include :: datetimepicker-js" />
    <script th:src="@{/ajax/libs/beautifyhtml/beautifyhtml.js}"></script>
	<script type="text/javascript">

        var prefix = ctx + "system/student";
        $('.summernote').summernote({
            placeholder: '请输入公告内容',
            height : 192,
            lang : 'zh-CN',
            followingToolbar: false,
            dialogsInBody: true,
            callbacks: {
                onImageUpload: function (files) {
                    sendFile(files[0], this);
                }
            }
        });

        // 上传文件
        function sendFile(file, obj) {
            var data = new FormData();
            data.append("file", file);
            $.ajax({
                type: "POST",
                url: ctx + "common/upload",
                data: data,
                cache: false,
                contentType: false,
                processData: false,
                dataType: 'json',
                success: function(result) {
                    if (result.code == web_status.SUCCESS) {
                        $(obj).summernote('editor.insertImage', result.url, result.fileName);
                    } else {
                        $.modal.alertError(result.msg);
                    }
                },
                error: function(error) {
                    $.modal.alertWarning("图片上传失败。");
                }
            });
        }

        $("#form-notice-add").validate({
            focusCleanup: true
        });


        function selectUser() {
            var url = prefix + '/selectUser';
            $.modal.open("选择用户", url);
        }
        
        function submitHandler() {
	        if ($.validate.form()) {
                var sHTML = $('.summernote').summernote('code');
                $("#content").val(sHTML);
	        	var data = $("#form-user-edit").serializeArray();

	        	$.operate.saveTab(prefix + "/development", data);
	        }
	    }


    </script>
</body>
</html>